import request from '@/utils/request'

// 查询用户项目关联列表
export function listUserProject(query) {
  return request({
    url: '/userProject/list',
    method: 'get',
    params: query
  })
}

// 查询用户项目关联详细
export function getUserProject(id) {
  return request({
    url: '/userProject/' + id,
    method: 'get'
  })
}

// 新增用户项目关联
export function addUserProject(data) {
  return request({
    url: '/userProject',
    method: 'post',
    data: data
  })
}

// 修改用户项目关联
export function updateUserProject(data) {
  return request({
    url: '/userProject',
    method: 'put',
    data: data
  })
}

// 删除用户项目关联
export function delUserProject(ids) {
  return request({
    url: '/userProject/' + ids,
    method: 'delete'
  })
}

// 导出用户项目关联
export function exportUserProject(query) {
  return request({
    url: '/userProject/export',
    method: 'get',
    params: query
  })
}

// 根据用户ID查询项目列表
export function getProjectsByUser(userId) {
  return request({
    url: '/userProject/projectsByUser/' + userId,
    method: 'get'
  })
}

// 根据项目ID查询用户列表
export function getUsersByProject(proId) {
  return request({
    url: '/userProject/usersByProject/' + proId,
    method: 'get'
  })
}

// 检查用户是否有指定项目的权限
export function checkUserProjectPermission(userId, proId) {
  return request({
    url: '/userProject/checkPermission/' + userId + '/' + proId,
    method: 'get'
  })
}

// 获取用户在项目中的权限等级
export function getUserProjectPermissionLevel(userId, proId) {
  return request({
    url: '/userProject/getPermissionLevel/' + userId + '/' + proId,
    method: 'get'
  })
}